package io.lvdaxian.mybatis13.executor;

import io.lvdaxian.mybatis13.mapping.BoundSql;
import io.lvdaxian.mybatis13.mapping.MappedStatement;
import io.lvdaxian.mybatis13.session.ResultHandler;
import io.lvdaxian.mybatis13.session.RowBounds;
import io.lvdaxian.mybatis13.transaction.Transaction;

import java.sql.SQLException;
import java.util.List;

/**
 * 定义 事务 sql, commit, rollback 等规范 等执行器执行标准
 *
 * @author lihh
 */
public interface Executor {
  ResultHandler NO_RESULT_HANDLER = null;
  
  // 这里统一的方式 定义update
  int update(MappedStatement ms, Object parameter) throws SQLException;
  
  // 这里定义了 执行规范
  <E> List<E> query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql);
  
  Transaction getTransaction();
  
  void commit(boolean required) throws SQLException;
  
  void rollback(boolean required) throws SQLException;
  
  void close(boolean forceRollback);
}
